<template>

    <el-dialog v-model="$store.state.homeview.dialogFormVisible" title="请输入修改内容">
        <el-form :model="form" :label-width="formLabelWidth">
            <el-form-item label="楼盘名称" :label-width="formLabelWidth">
                <el-input v-model="form.title" autocomplete="off" />
            </el-form-item>
            <el-form-item label="房源类型" :label-width="formLabelWidth">
                <el-input v-model="form.type" autocomplete="off" />
            </el-form-item>
            <el-form-item label="门牌号" :label-width="formLabelWidth">
                <el-input v-model="form.num" autocomplete="off" />
            </el-form-item>
            <el-form-item label="房源户型" :label-width="formLabelWidth">
                <el-input v-model="form.hometype" autocomplete="off" />
            </el-form-item>
            <el-form-item label="户主" :label-width="formLabelWidth">
                <el-input v-model="form.name" autocomplete="off" />
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <!-- 绑定函数 -->
                <el-button @click="toggleDialog(0)">取消</el-button>
                <el-button type="primary" @click="toggleDialog(1)">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue'
//引用useStore
import { useStore } from 'vuex';
import link from "../api/link.js"
import url from "../api/url.js"
//得到store对象
const store = useStore();
const dialogTableVisible = ref(false)
const dialogFormVisible = ref(false)
const formLabelWidth = '140px'
const form = reactive({
    name: '',
    region: '',
    date1: '',
    date2: '',
    delivery: false,
    type: [],
    resource: '',
    desc: '',
    title:"",
    num:"",
    hometype:""
})

let toggleDialog = (num: Number) => {
    // 调用vuex修改
    store.commit("SET_DIALOG")
    //得到输入框的值
    if (num == 0) {
        //   用户点击了取消
    } else {
        //   用户点击了确定
        //   得到输入框的值
        console.log(form.name + "---" + form.region);
        let data = {
            name: form.name, title: form.title, type: form.type, num: form.num, hometype: form.hometype
        }

        link(url.userlist + "/" + store.state.homeview.uplistData.id, "PUT", data).then((ok: any) => {
            console.log(ok)
        })
    }
}
</script>
<style scoped>
.el-button--text {
    margin-right: 15px;
}

.el-input {
    width: 300px;
}

.dialog-footer button:first-child {
    margin-right: 10px;
}
</style>